package o;

import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.NonNull;

public class box implements bpm {
    private final Context ˊ;
    private String ˎ;
    private final bpw ˏ;
    private int ॱ = -1;

    public box(Context context, bpw o_bpw) {
        this.ˊ = context;
        this.ˏ = o_bpw;
    }

    public void ˋ(boolean z) {
        if (z) {
            ˋ();
        } else {
            this.ˏ.ॱ(5, "Not signed the agreement.");
        }
    }

    public void ˎ(@NonNull String str, int i) {
        boc.ˎ.ˊ("GetInstallStateHandler", "getInstallState, pkgName: " + str + "sessionId: " + i);
        this.ˎ = str;
        this.ॱ = i;
        if (ccx.ॱ()) {
            ˋ();
            return;
        }
        boc.ˎ.ˏ("GetInstallStateHandler", "Require to sign the agreement.");
        bpp.ˏ().ˏ(this);
        new bpq(this.ˊ, this.ˎ).ˎ();
    }

    private void ˋ() {
        if (TextUtils.isEmpty(this.ˎ)) {
            boc.ˎ.ˊ("GetInstallStateHandler", "Run to unreachable logic.");
            return;
        }
        bol ˋ = bor.ˎ().ˋ(this.ॱ);
        if (ˋ == null || !ˋ.ˋ().equals(this.ˎ)) {
            this.ˏ.ॱ(7, "Not found the session, pkgName: " + this.ˎ + ", sessionId: " + this.ॱ);
        } else if (ˋ.ʼ()) {
            bqd ˊ = boz.ˊ(ˋ);
            if (ˊ == null) {
                this.ˏ.ॱ(7, "Not found the download or install task, pkgName: " + this.ˎ + ", sessionId: " + this.ॱ);
            } else {
                this.ˏ.ˏ(this.ॱ, ˊ);
            }
        } else {
            this.ˏ.ॱ(7, "Non 'startInstall' session, pkgName: " + this.ˎ + ", sessionId: " + this.ॱ);
        }
    }
}
